<?php

/**
 * Description of Dimension4Manager
 *
 * @author Yahn_V
 */
require_once('Dimension4.php');
require_once('Type.php');
class Dimension4Manager {

    public static function getList(Dimension2 $d2) {
        if (isset($d2)) {
            try {
                $pdo = PDO2::getInstance();
                $requete = $pdo->prepare("SELECT type, chiffre, d4.descr FROM  Dimension4 d4, Dimension2 d2
                                WHERE d4.refD1 = d2.refD1
                                AND d4.refD2 = d2.refD2
                                AND d4.refD1 =  :refD1
                                AND d4.refD2 = :refD2");

                $requete->bindValue(':refD2', $d2->getDimension2());
                $requete->bindValue(':refD1', $d2->getDimension1()->getRefD1());
                $requete->execute();
                $lesDimensions4 = array();
                while ($donnees = $requete->fetch(PDO::FETCH_OBJ)) {
                    
                    $type = $donnees->type;
                    $chiffre = $donnees->chiffre;
                    $descr = $donnees->descr;
                    $lesDimensions4[] = new Dimension4($d2->getDimension1(), $d2, new Type($type, "e"), $chiffre, $descr);
                }
            } catch (PDOException $e) {
                echo $e->getMessage();
            }
            return $lesDimensions4;
        }
    }

}

?>
